package com.test.mybatis.test_mybatis.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.mybatis.test_mybatis.entity.simple.Student;
import com.test.mybatis.test_mybatis.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wxb
 * @Datatime 2021/1/14 17:24
 * @Descript
 */
@RestController
@RequestMapping("student")
public class StudentController {

    @Autowired private StudentService studentService;

    @GetMapping("/{id}")
    public String selectById(@PathVariable Integer id){
        Student student = studentService.selectById(id);
        return student.toString();
    }

    @GetMapping("/list")
    public PageInfo getList(@RequestParam(defaultValue = "1") Integer page,
                        @RequestParam(defaultValue = "2") Integer rows){
        PageHelper.startPage(1,2);
        List list = studentService.selectList();
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

}
